package com.lemon.smartsafetynew.ui.activity.record;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.app.AppManager;
import com.lemon.smartsafetynew.entity.record.DustVo;
import com.lemon.smartsafetynew.ui.activity.base.SwipeBackActivity;
import com.lemon.smartsafetynew.util.common.CommonUtil;
import com.lemon.smartsafetynew.util.constants.KeyConstants;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 一企一档粉尘详情信息
 * Created by JiangAn on 2018/5/24.
 */

public class RecordDustDetailActivity extends SwipeBackActivity {
    @Bind(R.id.iv_return)
    ImageView ivReturn;
    @Bind(R.id.tv_dust_type)
    TextView tvDustType;
    @Bind(R.id.tv_dust_people_number)
    TextView tvDustPeopleNumber;
    @Bind(R.id.tv_dust_single_wrokers)
    TextView tvDustSingleWrokers;
    @Bind(R.id.tv_isHasCleaner)
    TextView tvIsHasCleaner;
    @Bind(R.id.tv_isVertify)
    TextView tvIsVertify;
    @Bind(R.id.tv_is_dust_cleaner)
    TextView tvIsDustCleaner;
    @Bind(R.id.tv_is_monitor)
    TextView tvIsMonitor;
    @Bind(R.id.tv_isRelateBomb)
    TextView tvIsRelateBomb;
    @Bind(R.id.tv_isDamage)
    TextView tvIsDamage;
    @Bind(R.id.tv_cleaner_count)
    TextView tvCleanerCount;
    @Bind(R.id.tv_cleaner_type)
    TextView tvCleanerType;
    @Bind(R.id.tv_space_remark)
    TextView tvSpaceRemark;

    private static DustVo data;
    @Bind(R.id.ll_cleaner_count)
    LinearLayout llCleanerCount;
    @Bind(R.id.ll_cleaner_type)
    LinearLayout llCleanerType;
    private Boolean isShowReturn = false;

    @Override
    protected void initTitle() {
        this.setBarTitle(getString(R.string.record_dust));
    }

    @Override
    protected void getBundleArgs() {
        super.getBundleArgs();

        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            data = (DustVo) bundle.getSerializable(KeyConstants.KEY_DUST_VO);
            isShowReturn = bundle.getBoolean("isShowReturn");
        }
    }

    @Override
    protected void callFinish() {
        AppManager.getAppManager().finishActivity(RecordDustDetailActivity.this);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_record_dust_detail;
    }

    @Override
    protected void initViews() {
        super.initViews();
        if (isShowReturn) {
            ivReturn.setVisibility(View.VISIBLE);
        } else {
            ivReturn.setVisibility(View.INVISIBLE);
        }
        if (data != null) {
            tvDustType.setText(CommonUtil.avoidNullString(data.getType()));
            tvDustPeopleNumber.setText(CommonUtil.avoidNullString(data.getWorkers()));
            tvDustSingleWrokers.setText(CommonUtil.avoidNullString(data.getShiftWorkers()));
            tvIsHasCleaner.setText(CommonUtil.avoidNullString(data.getDuster()));
            tvIsVertify.setText(CommonUtil.avoidNullString(data.getIsCheckout()));
            tvIsDustCleaner.setText(CommonUtil.avoidNullString(data.getCleanSystem()));
            tvIsMonitor.setText(CommonUtil.avoidNullString(data.getMonitor()));
            tvIsRelateBomb.setText(CommonUtil.avoidNullString(data.getIsBomb()));
            tvIsDamage.setText(CommonUtil.avoidNullString(data.getIsOccupational()));
            if ("是".equals(data.getDuster())) {
                llCleanerCount.setVisibility(View.VISIBLE);
                llCleanerType.setVisibility(View.VISIBLE);
                tvCleanerCount.setText(CommonUtil.avoidNullString(data.getDusterNumber()));
                tvCleanerType.setText(CommonUtil.avoidNullString(data.getDusterType()));
            } else {
                llCleanerCount.setVisibility(View.GONE);
                llCleanerType.setVisibility(View.GONE);
            }

            tvSpaceRemark.setText(CommonUtil.avoidNullString(data.getRemark()));
        }
    }

    @Override
    protected void initListener() {
        super.initListener();
        ivReturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppManager.getAppManager().finishActivity(RecordDustDetailActivity.this);
                AppManager.getAppManager().finishActivity(DustActivity.class);
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}


